<div id="form_item form_item_form_item">
	<div id="!{$item.id}_i_nav" class="i_nav">
		<a class="button" id="!{$item.id}_add_btn" href="javascript:void(0)">添加!{$item.name}</a>
	</div>
	<table class="list_table">
		<tr>
			<th>名称</th>
			<th>类型</th>
			<th>允许为空</th>
			<th>多语言</th>
			<th>操作</th>
		</tr>
		!{foreach from=$item.value item=fi key=code name=attr}
		<tr id="!{$item.id}_item_!{$code}">
			<td><label><input type="checkbox" name="code[]" value="!{$code}"/> !{$fi.name} [!{$code}] 
				!{if $fi.desc}<span class="ui-icon ui-icon-info" title="!{$fi.desc}"></span>!{/if}
			</label></td>
			<td>!{$fi.type_name}!{if $fi.relation_name} - !{$fi.relation_name} !{/if} !{if $fi.trait}<span>[!{$fi.trait_name}]</span>!{/if}</td>
			<td>!{if $fi.required eq true}<span class="ui-icon ui-icon-close"></span>!{else}<span class="ui-icon ui-icon-check"></span>!{/if}</td>
			<td>!{if $fi.mutil_lan eq true}<span class="ui-icon ui-icon-check"></span>!{else}<span class="ui-icon ui-icon-close"></span>!{/if}</td>
			<td>
				<a href="javascript:void(0)" onclick="attr_item_edit_!{$item.id}('!{$code}')"><span class="ui-icon ui-icon-pencil"></span>修改</a> 
				<a href="javascript:void(0)" onclick="attr_item_del_!{$item.id}('!{$fi._id}', '!{$code}')"><span class="ui-icon ui-icon-trash"></span>删除</a>
			</td>
		</tr>
		!{foreachelse}
		<tr><td colspan="5">暂无!{$item.name}</td></tr>
	!{/foreach}
	</table>
</div>
<script>
	$(function(){
		/**
		if(id=='0'){
			$("#!{$item.id}_add_btn").hide();
			//添加提示
			$("#!{$item.id}_i_nav").after('<div class="tips">保存后才可以添加!{$item.name}！</div>');
		}
		**/
		$('body').append('<div id="dialog_!{$item.id}" title="!{$item.name}编辑" class="dialog"></div>');
		$("#!{$item.id}_add_btn").click(function(){
			attr_item_edit_!{$item.id}();
		});
	});

	function attr_item_del_!{$item.id}(fid, code){
		if(confirm('删除将无法恢复，是否继续？')){
			var url = '/manager.php?app=attrs&act=item_del&module='+module+'&form_id=' + id + '&name=!{$item.id}&code=' + code;
			$.get(url,function(data){
				var json = eval('('+data+')');
				alert(json.info);
				if(json.result){
					$("#!{$item.id}_item_" + code).remove();
				}
			});
		}
	}
	
	function attr_item_edit_!{$item.id}(code){
		//此处id/module必须在外面赋值
		var url = '/index.php?app=form&act=item_edit&module='+module+'&form_id=' + id + '&name=!{$item.id}';
		if(code!=null){
			url += '&code=' + code;
		}
		$("#dialog_!{$item.id}").html('正在加载，请稍候...').dialog({width:700,height:420,modal:true,open:function(){
			//打开后加载
			$.get(url,function(html){
				$("#dialog_!{$item.id}").html(html);
				//加载提交
				$('#attr_form').ajax_form({
					'submit_btn' : '.submit_btn',
					'is_alert' : false
				});
			});
		}});
	}
</script>